package com.tang.param_check.controller;

import com.tang.param_check.aspect.annotation.ParamCheck;
import com.tang.param_check.aspect.handler.UserHandler;
import com.tang.param_check.domain.User;
import com.tang.param_check.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

/**
 * @Author tangyuan2meicloud.com
 * @DATE 2021/12/17 20:01
 * @Desc
 * @Remarks
 */
@RestController
public class TestController {

    @RequestMapping("/test")
    public String test(@ParamCheck(handleClass = UserHandler.class) @RequestBody User user) {
        System.out.println(user);
        return "Test";
    }

    @RequestMapping("/test2")
    public String test2(String user) {
        System.out.println(user);
        return "Test";
    }

    @RequestMapping("/test3")
    public String test3(@ParamCheck(handleClass = UserHandler.class) @RequestBody List<User> users) {
        System.out.println(users);
        return "Test";
    }

    @Autowired
    UserService userService;

    @RequestMapping("/test4")
    public String test4() {
        User user = new User();
        user.setName("aaaa");
        user.setId("11111");
        List<User> users = Arrays.asList(user);
        userService.test(users, user, users);
        return "Test";
    }
}
